//
//  DataModel.m
//  阅色(首页)
//
//  Created by 殷殷明静 on 16/9/9.
//  Copyright © 2016年 MJ.Y. All rights reserved.
//

#import "DataModel.h"

@implementation DataModel
- (void)setValue:(id)value forKey:(NSString *)key {
    [super setValue:value forKey:key];
    if ([key isEqualToString:@"imageDTOList"]) {
        NSMutableArray <DTOModel *> *arr = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            DTOModel *dto = [DTOModel modelWithDic:dic];
            [arr addObject:dto];
        }
        _imageDTOList = arr;
    }
    if ([key isEqualToString:@"id"]) {
        _channelId = value;
    }
    if ([key isEqualToString:@"newsImageInfoList"]) {
        NSMutableArray <NewsImageInfo *>*arr = [NSMutableArray array];
        
        for (NSDictionary *dic in value) {
            NewsImageInfo *newsInfo = [NewsImageInfo modelWithDic:dic];
            [arr addObject:newsInfo];
            
        }
        _newsImageInfoList = arr;
    }
    if ([key isEqualToString:@"newsSummaryInfoList"]) {
        NSMutableArray <NewsSummaryInfo *>*arr = [NSMutableArray array];
        
        for (NSDictionary *dic in value) {
            NewsSummaryInfo *sumInfo = [NewsSummaryInfo modelWithDic:dic];
            [arr addObject:sumInfo];
            
        }
        _newsSummaryInfoList = arr;
    }
   
    
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super init];
    if (self) {
        _origin = [aDecoder decodeObjectForKey:@"_origin"];
        _title = [aDecoder decodeObjectForKey:@"_title"];
        _summary = [aDecoder decodeObjectForKey:@"_summary"];
        _imageDTOList = [aDecoder decodeObjectForKey:@"imageDTOList"];
        _channelId = [aDecoder decodeObjectForKey:@"_channelId"];
        _srcLink = [aDecoder decodeObjectForKey:@"_srcLink"];
        _shareLink = [aDecoder decodeObjectForKey:@"_shareLink"];
        _newsImageInfoList = [aDecoder decodeObjectForKey:@"newsImageInfoList"];
        _messageId = [aDecoder decodeObjectForKey:@"_messageId"];
        _categoryIds = [aDecoder decodeObjectForKey:@"_categoryIds"];
        _messageType = [aDecoder decodeObjectForKey:@"_messageType"];
        _parentType = [aDecoder decodeObjectForKey:@"_parentType"];
        _parentId = [aDecoder decodeObjectForKey:@"_parentId"];
        _layoutType = [aDecoder decodeObjectForKey:@"_layoutType"];
        _engineType = [aDecoder decodeObjectForKey:@"_engineType"];
        
        
    }
    return self;
}
- (void)encodeWithCoder:(NSCoder *)aCoder {
    [aCoder encodeObject:_origin forKey:@"_origin"];
    [aCoder encodeObject:_title forKey:@"_title"];
    [aCoder encodeObject:_summary forKey:@"_summary"];
    [aCoder encodeObject:_imageDTOList forKey:@"imageDTOList"];
    [aCoder encodeObject:_channelId forKey:@"_channelId"];
    [aCoder encodeObject:_srcLink forKey:@"_srcLink"];
    [aCoder encodeObject:_shareLink forKey:@"_shareLink"];
    [aCoder encodeObject:_newsImageInfoList forKey:@"newsImageInfoList"];
    [aCoder encodeObject:_messageId forKey:@"_messageId"];
    [aCoder encodeObject:_categoryIds forKey:@"_categoryIds"];
    [aCoder encodeObject:_messageType forKey:@"_messageType"];
    [aCoder encodeObject:_parentType forKey:@"_parentType"];
    [aCoder encodeObject:_parentId forKey:@"_parentId"];
    [aCoder encodeObject:_layoutType forKey:@"_layoutType"];
    [aCoder encodeObject:_engineType forKey:@"_engineType'"];
    
    
}

@end
